package my.classes;

/**
 * Created by IntelliJ IDEA.
 * User: jtruelove
 * Date: 3/26/11
 * Time: 10:21 AM
 * To change this template use File | Settings | File Templates.
 */
public class Variance
{

    public void doThing(A theA)
    {

    }

    public A doOtherThing(B theB)
    {
            return theB;
    }

    public static void main (String [] args)
    {
        B newB = new B();
        Variance v = new Variance();

        // covariant - converting from a wider type to a narrower
        v.doThing(newB);

        // contravariant - converting from a narrower type to a wider
        A anotherA = v.doOtherThing(newB);

        // Generics are invariant
        //List<A> list = new ArrayList<B>();
    }
}

class A
{

}

class B extends A
{

}